package library.server;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Book {
	
	private String ISDN;
	private String title;
	private String publisher;
	private List<Author> authors;
	private float price;
	private Date publicationDate;
	
	public Book(){
		authors = new ArrayList<Author>();
		ISDN = "";
		title = "";
		publisher = "";
		publicationDate = new Date();
	}
	
	public Book(String iSDN, String title, String publisher,
			List<Author> authors, float price, Date publicationDate) {
		super();
		ISDN = iSDN;
		this.title = title;
		this.publisher = publisher;
		this.authors = authors;
		this.price = price;
		this.publicationDate = publicationDate;
	}

	public String getISDN() {
		return ISDN;
	}

	public String getTitle() {
		return title;
	}

	public String getPublisher() {
		return publisher;
	}

	public List<Author> getAuthors() {
		return authors;
	}

	public float getPrice() {
		return price;
	}

	public Date getPublicationDate() {
		return publicationDate;
	}
	
	public void setISDN(String iSDN) {
		ISDN = iSDN;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	public void setAuthors(List<Author> authors) {
		this.authors = authors;
	}
	
	public void setAuthor(Author author){
		this.authors.add(author);
	}

	public void setPrice(float price) {
		this.price = price;
	}

	public void setPublicationDate(Date publicationDate) {
		this.publicationDate = publicationDate;
	}

	public String ToString(){
		StringBuilder sb = new StringBuilder();
		sb.append("TITLE: ");
		sb.append(title);
		sb.append("\n");
		sb.append("ISDN: ");
		sb.append(ISDN);
		sb.append("\n");
		sb.append("PUBLISHER: ");
		sb.append(publisher);
		sb.append("\n");
		sb.append("AUTHORS: ");
		for (Author a : authors) {
			sb.append(a.getName()+" "+a.getSurname()+", ");
		}
		sb.append("\n");
		sb.append("PRICE: ");
		sb.append(price);
		sb.append("\n");
		sb.append("PUBLICATION DATE: ");
		sb.append(publicationDate);
		sb.append("\n");
		
		return sb.toString();
	}
}
